home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 37 / IOPROG_37.ISO / SOFT / Multilizer.exe / disk1 / data1.cab / data1 / [Group9]VCL Source Standard / ivdialog.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-12  |  31.7 KB  |  1,161 lines

  1. unit IvDialog;
  2.  
  3. {$I IVMULTI.INC}
  4.  
  5. interface
  6.  
  7. uses
  8. {$IFDEF WIN32}
  9.   Windows,
  10. {$ELSE}
  11.   WinTypes, WinProcs,
  12. {$ENDIF}
  13.   Messages, Dialogs, CommDlg,
  14.   IvDictio;
  15.  
  16. function IvGetOpenFileName(
  17.   var ofn: TOpenFilename;
  18.   dictionary: TIvDictionary;
  19.   center: Boolean;
  20.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  21.  
  22. function IvGetSaveFileName(
  23.   var ofn: TOpenFilename;
  24.   dictionary: TIvDictionary;
  25.   center: Boolean;
  26.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  27.  
  28. function IvChooseColor(
  29.   var cc: TChooseColor;
  30.   dictionary: TIvDictionary;
  31.   center: Boolean;
  32.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  33.  
  34. function IvChooseFont(
  35.   var cf: TChooseFont;
  36.   dictionary: TIvDictionary;
  37.   center: Boolean;
  38.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  39.  
  40. function IvFindText(
  41.   var fr: TFindReplace;
  42.   dictionary: TIvDictionary;
  43.   center: Boolean;
  44.   parent: HWnd): HWnd; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  45.  
  46. function IvReplaceText(
  47.   var fr: TFindReplace;
  48.   dictionary: TIvDictionary;
  49.   center: Boolean;
  50.   parent: HWnd): HWnd; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  51.  
  52. function IvPrintDlg(
  53.   var pd: TPrintDlg;
  54.   dictionary: TIvDictionary;
  55.   center: Boolean;
  56.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  57.  
  58. {$IFDEF WIN32}
  59. function IvPageSetupDlg(
  60.   var ps: TPageSetupDlg;
  61.   dictionary: TIvDictionary;
  62.   center: Boolean;
  63.   parent: HWnd): Bool; stdcall;
  64. {$ENDIF}
  65.  
  66. implementation
  67.  
  68. uses
  69. {$IFDEF WIN32}
  70.   CommCtrl,
  71. {$ENDIF}
  72.   SysUtils;
  73.  
  74. var
  75.   FDictionary: TIvDictionary;
  76.   FCenter: Boolean;
  77.   FParent: HWnd;
  78.   FCounter: Integer;
  79.   FOpenFile: TOpenFilename;
  80.   FWndProc, FHookProc, FSetupProc, FButtonProc: TFarProc;
  81. {$IFDEF WIN32}
  82.   FPS: TPageSetupDlg;
  83. {$ENDIF}
  84.  
  85. { Centers the window to the center of screen }
  86.  
  87. procedure CenterWindow(wnd: HWnd);
  88. var
  89.   rect, parentRect: TRect;
  90. begin
  91.   GetWindowRect(wnd, rect);
  92.   if FParent = 0 then
  93.   begin
  94.     SetWindowPos(
  95.       wnd,
  96.       0,
  97.       (GetSystemMetrics(SM_CXSCREEN) - (rect.Right - rect.Left)) div 2,
  98.       (GetSystemMetrics(SM_CYSCREEN) - (rect.Bottom - rect.Top)) div 2,
  99.       0,
  100.       0,
  101.       SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOZORDER);
  102.   end
  103.   else
  104.   begin
  105.     GetWindowRect(FParent, parentRect);
  106.     SetWindowPos(
  107.       wnd,
  108.       0,
  109.       parentRect.Left + (parentRect.Right - parentRect.Left - (rect.Right - rect.Left)) div 2,
  110.       parentRect.Top + (parentRect.Bottom - parentRect.Top - (rect.Bottom - rect.Top)) div 2,
  111.       0,
  112.       0,
  113.       SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOZORDER);
  114.   end;
  115. end;
  116.  
  117. {$IFDEF WIN32}
  118. { Window procedure of the explorer typed file dialogs }
  119.  
  120. function IvExplorerProc(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM): Integer; stdcall;
  121. type
  122. {$IFDEF IVWIDE}
  123.   PIvToolTipTextW = PToolTipTextW;
  124. {$ELSE}
  125.   // The COMMDTRL.PAS in Delphi 2 has an error
  126.  
  127.   PIvToolTipTextW = ^TIvToolTipTextW;
  128.   TIvToolTipTextW = packed record
  129.     hdr: TNMHDR;
  130.     lpszText: PWideChar;
  131.     szText: array[0..79] of WideChar;
  132.     hinst: THandle;
  133.     uFlags: UINT;
  134.   end;
  135. {$ENDIF}
  136. var
  137.   ttt: PIvToolTipTextW;
  138. begin
  139.   if msg = WM_NOTIFY then
  140.   begin
  141.     if PNMHDR(LParam).code = TTN_NEEDTEXTW then
  142.     begin
  143.       ttt := PIvToolTipTextW(LParam);
  144.       case ttt^.hdr.idFrom of
  145.         40961: IvWStrPCopy(
  146.           ttt^.szText,
  147.           IvStrToWStr(FDictionary.Translate('Up One Level'), FDictionary.LanguageData.CodePage));
  148.  
  149.         40962: IvWStrPCopy(
  150.           ttt^.szText,
  151.           IvStrToWStr(FDictionary.Translate('Create New Folder'), FDictionary.LanguageData.CodePage));
  152.  
  153.         40963: IvWStrPCopy(
  154.           ttt^.szText,
  155.           IvStrToWStr(FDictionary.Translate('List'), FDictionary.LanguageData.CodePage));
  156.  
  157.         40964: IvWStrPCopy(
  158.           ttt^.szText,
  159.           IvStrToWStr(FDictionary.Translate('Details'), FDictionary.LanguageData.CodePage));
  160.       end;
  161.       Result := 0;
  162.       Exit;
  163.     end;
  164.   end;
  165.  
  166.   Result := CallWindowProc(FWndProc, wnd, msg, wParam, lParam);
  167. end;
  168. {$ENDIF}
  169.  
  170.  
  171. { Open }
  172.  
  173. {$IFDEF WIN32}
  174. function TranslateExplorerOpenDialog(wnd: HWnd; reserved: Integer): Bool; stdcall;
  175. var
  176.   i, count: Integer;
  177.   buffer: array[0..255] of Char;
  178.   str: String;
  179.   headerItem: THDItem;
  180. begin
  181.   Result := True;
  182.  
  183.   { Translates the window text }
  184.  
  185.   GetClassName(wnd, buffer, SizeOf(buffer));
  186.   if buffer = WC_HEADER then
  187.   begin
  188.     { Translates a Header control }
  189.  
  190.     count := Header_GetItemCount(wnd);
  191.     for i := 0 to count - 1 do
  192.     begin
  193.       headerItem.mask := HDI_TEXT;
  194.       headerItem.pszText := buffer;
  195.       headerItem.cchTextMax := SizeOf(buffer);
  196.       Header_GetItem(wnd, i, headerItem);
  197.  
  198.       case i of
  199.         0: str := FDictionary.Translate('Name');
  200.         1: str := FDictionary.Translate('Size');
  201.         2: str := FDictionary.Translate('Type');
  202.         3: str := FDictionary.Translate('Modified');
  203.         4: str := FDictionary.Translate('Attributes');
  204.       else
  205.         str := FDictionary.Translate(headerItem.pszText);
  206.       end;
  207.  
  208.       if str <> buffer then
  209.       begin
  210.         headerItem.pszText := PChar(str);
  211.         Header_SetItem(wnd, i, headerItem);
  212.       end;
  213.     end;
  214.   end
  215.   else
  216.   begin
  217.     case GetWindowLong(wnd, GWL_ID) of
  218.       1: FDictionary.TranslateWindow(wnd, '&Open', True);
  219.       2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  220.       1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  221.       1040: FDictionary.TranslateWindow(wnd, 'Open as &read-only', True);
  222.       1089: FDictionary.TranslateWindow(wnd, 'Files of &type:', True);
  223.       1090: FDictionary.TranslateWindow(wnd, 'File &name:', True);
  224.       1091: FDictionary.TranslateWindow(wnd, 'Look &in:', True);
  225.     end;
  226.   end;
  227.  
  228.   { Translates the child controls }
  229.  
  230.   EnumChildWindows(wnd, @TranslateExplorerOpenDialog, 0);
  231. end;
  232.  
  233. function IvExplorerOpenHook(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM):
  234. {$IFDEF IVBIDI}
  235.   UINT;
  236. {$ELSE}
  237.   Integer;
  238. {$ENDIF}
  239.   stdcall;
  240. var
  241.   parentWnd: Integer;
  242. begin
  243.   Result := 0;
  244.   parentWnd := GetWindowLong(Wnd, GWL_HWNDPARENT);
  245.   case Msg of
  246.     WM_NOTIFY:
  247.     begin
  248.       if (POFNotify(LParam).hdr.code = CDN_INITDONE) and FCenter then
  249.         CenterWindow(parentWnd);
  250.  
  251.       if (POFNotify(LParam).hdr.code = CDN_FOLDERCHANGE) and (FDictionary <> nil) then
  252.       begin
  253.         if (FOpenFile.lpstrTitle <> nil) and (StrLen(FOpenFile.lpstrTitle) > 0) then
  254.           FDictionary.TranslateWindow(parentWnd, FOpenFile.lpstrTitle, False)
  255.         else
  256.           FDictionary.TranslateWindow(parentWnd, 'Open', False);
  257.         TranslateExplorerOpenDialog(parentWnd, 0);
  258.         if not Assigned(FWndProc) then
  259.         begin
  260.           FWndProc := TFarProc(GetWindowLong(parentWnd, GWL_WNDPROC));
  261.           SetWindowLong(parentWnd, GWL_WNDPROC, Integer(@IvExplorerProc));
  262.         end;
  263.       end;
  264.     end;
  265.   end;
  266.  
  267.   if Assigned(FHookProc) then
  268.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  269. end;
  270. {$ENDIF}
  271.  
  272. function TranslateOpenDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  273. begin
  274.   Result := True;
  275.  
  276.   { Translates the window text }
  277.  
  278. {$IFDEF WIN32}
  279.   case GetWindowLong(wnd, GWL_ID) of
  280. {$ELSE}
  281.   case GetWindowWord(wnd, GWW_ID) of
  282. {$ENDIF}
  283.     1: FDictionary.TranslateWindow(wnd, 'OK', True);
  284.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  285.     1037: FDictionary.TranslateWindow(wnd, 'Net&work...', True);
  286.     1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  287.     1040: FDictionary.TranslateWindow(wnd, '&Read only', True);
  288.     1089: FDictionary.TranslateWindow(wnd, 'List files of &type:', True);
  289.     1090: FDictionary.TranslateWindow(wnd, 'File &name:', True);
  290.     1091: FDictionary.TranslateWindow(wnd, 'Dri&ves:', True);
  291.     65535: FDictionary.TranslateWindow(wnd, '&Folders:', True);
  292.   end;
  293.  
  294.   { Translates the child controls }
  295.  
  296.   EnumChildWindows(wnd, @TranslateOpenDialog, 0);
  297. end;
  298.  
  299. {$IFDEF WIN32}
  300. function IvOpenHook(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM):
  301. {$IFDEF IVBIDI}
  302.   UINT;
  303. {$ELSE}
  304.   Integer;
  305. {$ENDIF}
  306.   stdcall;
  307. {$ELSE}
  308. function IvOpenHook(wnd: HWnd; msg, wParam: Word; lParam: Longint): Word; export;
  309. {$ENDIF}
  310. begin
  311.   Result := 0;
  312.   case Msg of
  313.     WM_INITDIALOG:
  314.       if FCenter then
  315.         CenterWindow(Wnd);
  316.  
  317.     WM_ACTIVATE:
  318.       if (LOWORD(WParam) = WA_ACTIVE) and (FDictionary <> nil) then
  319.       begin
  320.         if (FOpenFile.lpstrTitle <> nil) and (StrLen(FOpenFile.lpstrTitle) > 0) then
  321.           FDictionary.TranslateWindow(
  322.             wnd,
  323. {$IFDEF WIN32}
  324.             FOpenFile.lpstrTitle,
  325. {$ELSE}
  326.             StrPas(FOpenFile.lpstrTitle),
  327. {$ENDIF}
  328.             False)
  329.         else
  330.           FDictionary.TranslateWindow(wnd, 'Open', False);
  331.         TranslateOpenDialog(wnd, 0);
  332.       end;
  333.   end;
  334.  
  335.   if Assigned(FHookProc) then
  336.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  337. end;
  338.  
  339. function IvGetOpenFileName(
  340.   var ofn: TOpenFilename;
  341.   dictionary: TIvDictionary;
  342.   center: Boolean;
  343.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ENDIF}
  344. begin
  345.   FDictionary := dictionary;
  346.   FCenter := center;
  347.   FParent := parent;
  348.   FOpenFile := ofn;
  349.   FWndProc := nil;
  350.  
  351.   if Assigned(ofn.lpfnHook) then
  352.     FHookProc := @ofn.lpfnHook
  353.   else
  354.     FHookProc := nil;
  355.  
  356.   ofn.flags := ofn.flags or OFN_ENABLEHOOK;
  357. {$IFDEF WIN32}
  358.   if (ofn.flags and OFN_EXPLORER) <> 0 then
  359.     ofn.lpfnHook := IvExplorerOpenHook
  360.   else
  361. {$ENDIF}
  362.     ofn.lpfnHook := IvOpenHook;
  363.  
  364.   Result := GetOpenFileName(ofn);
  365. end;
  366.  
  367.  
  368. { Save }
  369.  
  370. {$IFDEF WIN32}
  371. function IvButtonProc(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM): Integer; stdcall;
  372. begin
  373.   if msg <> WM_SETTEXT then
  374.     Result := CallWindowProc(FButtonProc, wnd, msg, wParam, lParam)
  375.   else
  376.     Result := Integer(True);
  377. end;
  378.  
  379. function TranslateExplorerSaveDialog(wnd: HWnd; reserved: Integer): Bool; stdcall;
  380. const
  381.   TEST_C = 'test';
  382. var
  383.   i, count: Integer;
  384.   buffer: array[0..255] of Char;
  385.   str: String;
  386.   headerItem: THDItem;
  387. begin
  388.   Result := True;
  389.  
  390.   { Translates the window text }
  391.  
  392.   GetClassName(wnd, buffer, SizeOf(buffer));
  393.   if buffer = WC_HEADER then
  394.   begin
  395.     { Translates a Header control }
  396.  
  397.     count := Header_GetItemCount(wnd);
  398.     for i := 0 to count - 1 do
  399.     begin
  400.       headerItem.mask := HDI_TEXT;
  401.       headerItem.pszText := buffer;
  402.       headerItem.cchTextMax := SizeOf(buffer);
  403.       Header_GetItem(wnd, i, headerItem);
  404.  
  405.       case i of
  406.         0: str := FDictionary.Translate('Name');
  407.         1: str := FDictionary.Translate('Size');
  408.         2: str := FDictionary.Translate('Type');
  409.         3: str := FDictionary.Translate('Modified');
  410.         4: str := FDictionary.Translate('Attributes');
  411.       else
  412.         str := FDictionary.Translate(headerItem.pszText);
  413.       end;
  414.       
  415.       if str <> buffer then
  416.       begin
  417.         headerItem.pszText := PChar(str);
  418.         Header_SetItem(wnd, i, headerItem);
  419.       end;
  420.     end;
  421.   end
  422.   else
  423.   begin
  424.     case GetWindowLong(wnd, GWL_ID) of
  425.       1:
  426.       begin
  427.         FDictionary.TranslateWindow(wnd, '&Save', True);
  428.         if not Assigned(FButtonProc) then
  429.         begin
  430.           FButtonProc := TFarProc(GetWindowLong(wnd, GWL_WNDPROC));
  431.           SetWindowLong(wnd, GWL_WNDPROC, Integer(@IvButtonProc));
  432.         end;
  433.       end;
  434.  
  435.       2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  436.       1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  437.       1040: FDictionary.TranslateWindow(wnd, 'Open as &read-only', True);
  438.       1089: FDictionary.TranslateWindow(wnd, 'Save as &type:', True);
  439.       1090: FDictionary.TranslateWindow(wnd, 'File &name:', True);
  440.       1091: FDictionary.TranslateWindow(wnd, 'Save &in:', True);
  441.     end;
  442.   end;
  443.  
  444.   { Translates the child controls }
  445.  
  446.   EnumChildWindows(wnd, @TranslateExplorerSaveDialog, 0);
  447. end;
  448.  
  449. function IvExplorerSaveHook(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM):
  450. {$IFDEF IVBIDI}
  451.   UINT;
  452. {$ELSE}
  453.   Integer;
  454. {$ENDIF}
  455.   stdcall;
  456. var
  457.   parentWnd: Integer;
  458. begin
  459.   Result := Integer(True);
  460.   parentWnd := GetWindowLong(Wnd, GWL_HWNDPARENT);
  461.   case Msg of
  462.     WM_NOTIFY:
  463.     begin
  464.       if (POFNotify(LParam).hdr.code = CDN_INITDONE) and FCenter then
  465.         CenterWindow(parentWnd);
  466.  
  467.       if (FOpenFile.lpstrTitle <> nil) and (StrLen(FOpenFile.lpstrTitle) > 0) then
  468.         FDictionary.TranslateWindow(parentWnd, FOpenFile.lpstrTitle, False)
  469.       else
  470.         FDictionary.TranslateWindow(parentWnd, 'Save As', False);
  471.       TranslateExplorerSaveDialog(parentWnd, 0);
  472.       if not Assigned(FWndProc) then
  473.       begin
  474.         FWndProc := TFarProc(GetWindowLong(parentWnd, GWL_WNDPROC));
  475.         SetWindowLong(parentWnd, GWL_WNDPROC, Integer(@IvExplorerProc));
  476.       end;
  477.     end;
  478.   end;
  479.  
  480.   if Assigned(FHookProc) then
  481.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  482. end;
  483. {$ENDIF}
  484.  
  485. function TranslateSaveDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  486. begin
  487.   Result := True;
  488.  
  489.   { Translates the window text }
  490.  
  491. {$IFDEF WIN32}
  492.   case GetWindowLong(wnd, GWL_ID) of
  493. {$ELSE}
  494.   case GetWindowWord(wnd, GWW_ID) of
  495. {$ENDIF}
  496.     1: FDictionary.TranslateWindow(wnd, 'OK', True);
  497.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  498.     1037: FDictionary.TranslateWindow(wnd, 'Net&work...', True);
  499.     1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  500.     1040: FDictionary.TranslateWindow(wnd, '&Read only', True);
  501.     1089: FDictionary.TranslateWindow(wnd, 'Save file as &type:', True);
  502.     1090: FDictionary.TranslateWindow(wnd, 'File &name:', True);
  503.     1091: FDictionary.TranslateWindow(wnd, 'Dri&ves:', True);
  504.     65535: FDictionary.TranslateWindow(wnd, '&Folders:', True);
  505.   end;
  506.  
  507.   { Translates the child controls }
  508.  
  509.   EnumChildWindows(wnd, @TranslateSaveDialog, 0);
  510. end;
  511.  
  512. {$IFDEF WIN32}
  513. function IvSaveHook(Wnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
  514. {$IFDEF IVBIDI}
  515.   UINT;
  516. {$ELSE}
  517.   Integer;
  518. {$ENDIF}
  519.   stdcall;
  520. {$ELSE}
  521. function IvSaveHook(Wnd: HWnd; Msg, WParam: Word; LParam: Longint): Word; export;
  522. {$ENDIF}
  523. begin
  524.   Result := 0;
  525.   case Msg of
  526.     WM_INITDIALOG:
  527.       if FCenter then
  528.         CenterWindow(Wnd);
  529.  
  530.     WM_ACTIVATE:
  531.       if (LOWORD(WParam) = WA_ACTIVE) and (FDictionary <> nil) then
  532.       begin
  533.         if (FOpenFile.lpstrTitle <> nil) and (StrLen(FOpenFile.lpstrTitle) > 0) then
  534.           FDictionary.TranslateWindow(
  535.             wnd,
  536. {$IFDEF WIN32}
  537.             FOpenFile.lpstrTitle,
  538. {$ELSE}
  539.             StrPas(FOpenFile.lpstrTitle),
  540. {$ENDIF}
  541.             False)
  542.         else
  543.           FDictionary.TranslateWindow(wnd, 'Save As', False);
  544.         TranslateSaveDialog(Wnd, 0);
  545.       end;
  546.   end;
  547.  
  548.   if Assigned(FHookProc) then
  549.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  550. end;
  551.  
  552. function IvGetSaveFileName(
  553.   var ofn: TOpenFilename;
  554.   dictionary: TIvDictionary;
  555.   center: Boolean;
  556.   parent: HWnd): Bool; {$IFDEF WIN32}stdcall;{$ENDIF}
  557. begin
  558.   FDictionary := dictionary;
  559.   FCenter := center;
  560.   FParent := parent;
  561.   FWndProc := nil;
  562.   FButtonProc := nil;
  563.   FOpenFile := ofn;
  564.  
  565.   if Assigned(ofn.lpfnHook) then
  566.     FHookProc := @ofn.lpfnHook
  567.   else
  568.     FHookProc := nil;
  569.  
  570.   ofn.flags := ofn.flags or OFN_ENABLEHOOK;
  571. {$IFDEF WIN32}
  572.   if (ofn.flags and OFN_EXPLORER) <> 0 then
  573.     ofn.lpfnHook := IvExplorerSaveHook
  574.   else
  575. {$ENDIF}
  576.     ofn.lpfnHook := IvSaveHook;
  577.  
  578.   Result := GetSaveFileName(ofn);
  579. end;
  580.  
  581.  
  582. { Color }
  583.  
  584. function TranslateColorDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  585. begin
  586.   Result := True;
  587.  
  588.   { Translates the window text }
  589.  
  590. {$IFDEF WIN32}
  591.   case GetWindowLong(wnd, GWL_ID) of
  592. {$ELSE}
  593.   case GetWindowWord(wnd, GWW_ID) of
  594. {$ENDIF}
  595.     0: FDictionary.TranslateWindow(wnd, 'Color', False);
  596.     1: FDictionary.TranslateWindow(wnd, 'OK', True);
  597.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  598.     712: FDictionary.TranslateWindow(wnd, '&Add to Custom Colors', True);
  599.     719: FDictionary.TranslateWindow(wnd, '&Define Custom Colors >>', True);
  600.     723: FDictionary.TranslateWindow(wnd, 'Hu&e:', True);
  601.     724: FDictionary.TranslateWindow(wnd, '&Sat:', True);
  602.     725: FDictionary.TranslateWindow(wnd, '&Lum:', True);
  603.     726: FDictionary.TranslateWindow(wnd, '&Red:', True);
  604.     727: FDictionary.TranslateWindow(wnd, '&Green:', True);
  605.     728: FDictionary.TranslateWindow(wnd, 'Bl&ue:', True);
  606.     730: FDictionary.TranslateWindow(wnd, 'Color', True);
  607.     731: FDictionary.TranslateWindow(wnd, '|S&olid', True);
  608.     1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  609.     65535:
  610.       begin
  611.         case FCounter of
  612.           0: FDictionary.TranslateWindow(wnd, '&Basic colors:', True);
  613.           1: FDictionary.TranslateWindow(wnd, '&Custom colors:', True);
  614.         end;
  615.         Inc(FCounter);
  616.       end;
  617.   end;
  618.  
  619.   { Translates the child controls }
  620.  
  621.   EnumChildWindows(wnd, @TranslateColorDialog, 0);
  622. end;
  623.  
  624. {$IFDEF WIN32}
  625. function IvColorHook(Wnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
  626. {$IFDEF IVBIDI}
  627.   UINT;
  628. {$ELSE}
  629.   Integer;
  630. {$ENDIF}
  631.   stdcall;
  632. {$ELSE}
  633. function IvColorHook(Wnd: HWnd; Msg, WParam: Word; LParam: Longint): Word; export;
  634. {$ENDIF}
  635. begin
  636.   Result := 0;
  637.   case Msg of
  638.     WM_INITDIALOG:
  639.       if FCenter then
  640.         CenterWindow(Wnd);
  641.  
  642.     WM_ACTIVATE:
  643.       if (LOWORD(WParam) = WA_ACTIVE) and (FDictionary <> nil) then
  644.       begin
  645.         FCounter := 0;
  646.         TranslateColorDialog(Wnd, 0);
  647.       end;
  648.   end;
  649.  
  650.   if Assigned(FHookProc) then
  651.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  652. end;
  653.  
  654. function IvChooseColor(
  655.   var cc: TChooseColor;
  656.   dictionary: TIvDictionary;
  657.   center: Boolean;
  658.   parent: HWnd): Bool;
  659. begin
  660.   FDictionary := dictionary;
  661.   FCenter := center;
  662.   FParent := parent;
  663.   cc.flags := cc.flags or CC_ENABLEHOOK;
  664.   if Assigned(cc.lpfnHook) then
  665.     FHookProc := @cc.lpfnHook
  666.   else
  667.     FHookProc := nil;
  668.   cc.lpfnHook := IvColorHook;
  669.   Result := ChooseColor(cc);
  670. end;
  671.  
  672.  
  673. { Font }
  674.  
  675. function TranslateFontDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  676. begin
  677.   Result := True;
  678.  
  679.   { Translates the window text }
  680.  
  681. {$IFDEF WIN32}
  682.   case GetWindowLong(wnd, GWL_ID) of
  683. {$ELSE}
  684.   case GetWindowWord(wnd, GWW_ID) of
  685. {$ENDIF}
  686.     0: FDictionary.TranslateWindow(wnd, 'Font', False);
  687.     1: FDictionary.TranslateWindow(wnd, 'OK', True);
  688.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  689.     1026: FDictionary.TranslateWindow(wnd, '&Apply', True);
  690.     1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  691.     1040: FDictionary.TranslateWindow(wnd, 'Stri&keout', True);
  692.     1041: FDictionary.TranslateWindow(wnd, '&Underline', True);
  693.     1072: FDictionary.TranslateWindow(wnd, 'Effects', True);
  694.     1073: FDictionary.TranslateWindow(wnd, 'Sample', True);
  695.     1088: FDictionary.TranslateWindow(wnd, '&Font:', True);
  696.     1089: FDictionary.TranslateWindow(wnd, 'Font st&yle:', True);
  697.     1090: FDictionary.TranslateWindow(wnd, '&Size:', True);
  698.     1091: FDictionary.TranslateWindow(wnd, '&Color:', True);
  699.     1094: FDictionary.TranslateWindow(wnd, 'Sc&ript:', True);
  700.   end;
  701.  
  702.   { Translates the child controls }
  703.  
  704.   EnumChildWindows(wnd, @TranslateFontDialog, 0);
  705. end;
  706.  
  707. {$IFDEF WIN32}
  708. function IvFontHook(Wnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
  709. {$IFDEF IVBIDI}
  710.   UINT;
  711. {$ELSE}
  712.   Integer;
  713. {$ENDIF}
  714.   stdcall;
  715. {$ELSE}
  716. function IvFontHook(Wnd: HWnd; Msg, WParam: Word; LParam: Longint): Word; export;
  717. {$ENDIF}
  718. begin
  719.   Result := 0;
  720.   case Msg of
  721.     WM_INITDIALOG:
  722.       if FCenter then
  723.         CenterWindow(Wnd);
  724.  
  725.     WM_ACTIVATE:
  726.       if (LOWORD(WParam) = WA_ACTIVE) and (FDictionary <> nil) then
  727.         TranslateFontDialog(Wnd, 0);
  728.   end;
  729.  
  730.   if Assigned(FHookProc) then
  731.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  732. end;
  733.  
  734. function IvChooseFont(
  735.   var cf: TChooseFont;
  736.   dictionary: TIvDictionary;
  737.   center: Boolean;
  738.   parent: HWnd): Bool;
  739. begin
  740.   FDictionary := dictionary;
  741.   FCenter := center;
  742.   FParent := parent;
  743.   cf.flags := cf.flags or CF_ENABLEHOOK;
  744.   if Assigned(cf.lpfnHook) then
  745.     FHookProc := @cf.lpfnHook
  746.   else
  747.     FHookProc := nil;
  748.   cf.lpfnHook := IvFontHook;
  749.   Result := ChooseFont(cf);
  750. end;
  751.  
  752.  
  753. { Find }
  754.  
  755. function TranslateFindDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  756. begin
  757.   Result := True;
  758.  
  759.   { Translates the window text }
  760.  
  761. {$IFDEF WIN32}
  762.   case GetWindowLong(wnd, GWL_ID) of
  763. {$ELSE}
  764.   case GetWindowWord(wnd, GWW_ID) of
  765. {$ENDIF}
  766.     0: FDictionary.TranslateWindow(wnd, 'Find', False);
  767.     1: FDictionary.TranslateWindow(wnd, '&Find Next', True);
  768.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  769.     1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  770.     1040: FDictionary.TranslateWindow(wnd, 'Match &whole word only', True);
  771.     1041: FDictionary.TranslateWindow(wnd, 'Match &case', True);
  772.     1056: FDictionary.TranslateWindow(wnd, '&Up', True);
  773.     1057: FDictionary.TranslateWindow(wnd, '&Down', True);
  774.     1072: FDictionary.TranslateWindow(wnd, 'Direction', True);
  775.     65535: FDictionary.TranslateWindow(wnd, 'Fi&nd what:', True);
  776.   end;
  777.  
  778.   { Translates the child controls }
  779.  
  780.   EnumChildWindows(wnd, @TranslateFindDialog, 0);
  781. end;
  782.  
  783. {$IFDEF WIN32}
  784. function IvFindHook(Wnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
  785. {$IFDEF IVBIDI}
  786.   UINT;
  787. {$ELSE}
  788.   Integer;
  789. {$ENDIF}
  790.   stdcall;
  791. {$ELSE}
  792. function IvFindHook(Wnd: HWnd; Msg, WParam: Word; LParam: Longint): Word; export;
  793. {$ENDIF}
  794. begin
  795.   Result := 0;
  796.   case Msg of
  797.     WM_INITDIALOG:
  798.       if FCenter then
  799.         CenterWindow(Wnd);
  800.  
  801.     WM_ACTIVATE:
  802.       if (LOWORD(WParam) = WA_ACTIVE) and (FDictionary <> nil) then
  803.         TranslateFindDialog(Wnd, 0);
  804.   end;
  805.  
  806.   if Assigned(FHookProc) then
  807.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  808. end;
  809.  
  810. function IvFindText(
  811.   var fr: TFindReplace;
  812.   dictionary: TIvDictionary;
  813.   center: Boolean;
  814.   parent: HWnd): HWND;
  815. begin
  816.   FDictionary := dictionary;
  817.   FCenter := center;
  818.   FParent := parent;
  819.   fr.flags := fr.flags or FR_ENABLEHOOK;
  820.   if Assigned(fr.lpfnHook) then
  821.     FHookProc := @fr.lpfnHook
  822.   else
  823.     FHookProc := nil;
  824.   fr.lpfnHook := IvFindHook;
  825.   Result := FindText(fr);
  826. end;
  827.  
  828.  
  829. { Replace }
  830.  
  831. function TranslateReplaceDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  832. begin
  833.   Result := True;
  834.  
  835.   { Translates the window text }
  836.  
  837. {$IFDEF WIN32}
  838.   case GetWindowLong(wnd, GWL_ID) of
  839. {$ELSE}
  840.   case GetWindowWord(wnd, GWW_ID) of
  841. {$ENDIF}
  842.     0: FDictionary.TranslateWindow(wnd, 'Replace', False);
  843.     1: FDictionary.TranslateWindow(wnd, '&Find Next', True);
  844.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  845.     1038: FDictionary.TranslateWindow(wnd, '&Help', True);
  846.     1024: FDictionary.TranslateWindow(wnd, '&Replace', True);
  847.     1025: FDictionary.TranslateWindow(wnd, 'Replace &All', True);
  848.     1040: FDictionary.TranslateWindow(wnd, 'Match &whole word only', True);
  849.     1041: FDictionary.TranslateWindow(wnd, 'Match &case', True);
  850.     65535:
  851.       begin
  852.         case FCounter of
  853.           0: FDictionary.TranslateWindow(wnd, 'Fi&nd what:', True);
  854.           1: FDictionary.TranslateWindow(wnd, 'Re&place with:', True);
  855.         end;
  856.         Inc(FCounter);
  857.       end;
  858.   end;
  859.  
  860.   { Translates the child controls }
  861.  
  862.   EnumChildWindows(wnd, @TranslateReplaceDialog, 0);
  863. end;
  864.  
  865. {$IFDEF WIN32}
  866. function IvReplaceHook(Wnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM):
  867. {$IFDEF IVBIDI}
  868.   UINT;
  869. {$ELSE}
  870.   Integer;
  871. {$ENDIF}
  872.   stdcall;
  873. {$ELSE}
  874. function IvReplaceHook(Wnd: HWnd; Msg, WParam: Word; LParam: Longint): Word; export;
  875. {$ENDIF}
  876. begin
  877.   Result := 0;
  878.   case Msg of
  879.     WM_INITDIALOG:
  880.       if FCenter then
  881.         CenterWindow(Wnd);
  882.  
  883.     WM_ACTIVATE:
  884.       if (LOWORD(WParam) = WA_ACTIVE) and (FDictionary <> nil) then
  885.       begin
  886.         FCounter := 0;
  887.         TranslateReplaceDialog(Wnd, 0);
  888.       end;
  889.   end;
  890.  
  891.   if Assigned(FHookProc) then
  892.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  893. end;
  894.  
  895. function IvReplaceText(
  896.   var fr: TFindReplace;
  897.   dictionary: TIvDictionary;
  898.   center: Boolean;
  899.   parent: HWnd): HWnd;
  900. begin
  901.   FDictionary := dictionary;
  902.   FCenter := center;
  903.   FParent := parent;
  904.   fr.flags := fr.flags or FR_ENABLEHOOK;
  905.   if Assigned(fr.lpfnHook) then
  906.     FHookProc := @fr.lpfnHook
  907.   else
  908.     FHookProc := nil;
  909.   fr.lpfnHook := IvReplaceHook;
  910.   Result := ReplaceText(fr);
  911. end;
  912.  
  913.  
  914. { Print and Priner Setup dialogs }
  915.  
  916. function TranslatePrintDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  917. begin
  918.   Result := True;
  919.  
  920.   { Translates the window text }
  921.  
  922. {$IFDEF WIN32}
  923.   case GetWindowLong(wnd, GWL_ID) of
  924. {$ELSE}
  925.   case GetWindowWord(wnd, GWW_ID) of
  926. {$ENDIF}
  927.     0: FDictionary.TranslateWindow(wnd, 'Print', False);
  928.     1: FDictionary.TranslateWindow(wnd, 'OK', True);
  929.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  930.  
  931.     1025: FDictionary.TranslateWindow(wnd, '&Properties', True);
  932.     1040: FDictionary.TranslateWindow(wnd, 'Print to fi&le', True);
  933.     1041: FDictionary.TranslateWindow(wnd, 'C&ollate', True);
  934.     1056: FDictionary.TranslateWindow(wnd, '&All', True);
  935.     1057: FDictionary.TranslateWindow(wnd, '&Selection', True);
  936.     1058: FDictionary.TranslateWindow(wnd, 'Pa&ges', True);
  937.     1072: FDictionary.TranslateWindow(wnd, 'Print range', True);
  938.     1073: FDictionary.TranslateWindow(wnd, 'Copies', True);
  939.     1075: FDictionary.TranslateWindow(wnd, 'Printer', True);
  940.     1089: FDictionary.TranslateWindow(wnd, '&from:', True);
  941.     1090: FDictionary.TranslateWindow(wnd, '&to:', True);
  942.     1092: FDictionary.TranslateWindow(wnd, 'Number of &copies:', True);
  943.     1093: FDictionary.TranslateWindow(wnd, '&Name:', True);
  944.     1094: FDictionary.TranslateWindow(wnd, 'Type:', True);
  945.     1095: FDictionary.TranslateWindow(wnd, 'Status:', True);
  946.     1096: FDictionary.TranslateWindow(wnd, 'Comment:', True);
  947.     1097: FDictionary.TranslateWindow(wnd, 'Where:', True);
  948.   end;
  949.  
  950.   { Translates the child controls }
  951.  
  952.   EnumChildWindows(wnd, @TranslatePrintDialog, 0);
  953. end;
  954.  
  955. {$IFDEF WIN32}
  956. function IvPrintHook(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM):
  957. {$IFDEF IVBIDI}
  958.   UINT;
  959. {$ELSE}
  960.   Integer;
  961. {$ENDIF}
  962.   stdcall;
  963. {$ELSE}
  964. function IvPrintHook(wnd: HWnd; msg, wParam: Word; lParam: Longint): Word; export;
  965. {$ENDIF}
  966. begin
  967.   Result := 0;
  968.   case Msg of
  969.     WM_INITDIALOG:
  970.       if FCenter then
  971.         CenterWindow(wnd);
  972.  
  973.     WM_ACTIVATE:
  974.       if (LOWORD(wParam) = WA_ACTIVE) and (FDictionary <> nil) then
  975.         TranslatePrintDialog(wnd, 0);
  976.   end;
  977.  
  978.   if Assigned(FHookProc) then
  979.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  980. end;
  981.  
  982. function TranslatePrinterDialog(wnd: HWnd; reserved: Integer): Bool; {$IFDEF WIN32}stdcall;{$ELSE}export;{$ENDIF}
  983. begin
  984.   Result := True;
  985.  
  986.   { Translates the window text }
  987.  
  988. {$IFDEF WIN32}
  989.   case GetWindowLong(wnd, GWL_ID) of
  990. {$ELSE}
  991.   case GetWindowWord(wnd, GWW_ID) of
  992. {$ENDIF}
  993.     0: FDictionary.TranslateWindow(wnd, 'Print Setup', False);
  994.     1: FDictionary.TranslateWindow(wnd, 'OK', True);
  995.     2: FDictionary.TranslateWindow(wnd, 'Cancel', True);
  996.  
  997.     1025: FDictionary.TranslateWindow(wnd, '&Properties', True);
  998.     1037: FDictionary.TranslateWindow(wnd, 'Net&work...', True);
  999.     1056: FDictionary.TranslateWindow(wnd, 'P&ortrait', True);
  1000.     1057: FDictionary.TranslateWindow(wnd, 'L&andscape', True);
  1001.     1072: FDictionary.TranslateWindow(wnd, 'Orientation', True);
  1002.     1073: FDictionary.TranslateWindow(wnd, 'Paper', True);
  1003.     1075: FDictionary.TranslateWindow(wnd, 'Printer', True);
  1004.     1089: FDictionary.TranslateWindow(wnd, 'Si&ze:', True);
  1005.     1090: FDictionary.TranslateWindow(wnd, '&Source:', True);
  1006.     1093: FDictionary.TranslateWindow(wnd, '&Name:', True);
  1007.     1094: FDictionary.TranslateWindow(wnd, 'Type:', True);
  1008.     1095: FDictionary.TranslateWindow(wnd, 'Status:', True);
  1009.     1096: FDictionary.TranslateWindow(wnd, 'Comment:', True);
  1010.     1097: FDictionary.TranslateWindow(wnd, 'Where:', True);
  1011.   end;
  1012.  
  1013.   { Translates the child controls }
  1014.  
  1015.   EnumChildWindows(wnd, @TranslatePrinterDialog, 0);
  1016. end;
  1017.  
  1018. {$IFDEF WIN32}
  1019. function IvSetupHook(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM):
  1020. {$IFDEF IVBIDI}
  1021.   UINT;
  1022. {$ELSE}
  1023.   Integer;
  1024. {$ENDIF}
  1025.   stdcall;
  1026. {$ELSE}
  1027. function IvSetupHook(wnd: HWnd; msg, wParam: Word; lParam: Longint): Word; export;
  1028. {$ENDIF}
  1029. begin
  1030.   Result := 0;
  1031.   case Msg of
  1032.     WM_INITDIALOG:
  1033.       if FCenter then
  1034.         CenterWindow(wnd);
  1035.  
  1036.     WM_ACTIVATE:
  1037.       if (LOWORD(wParam) = WA_ACTIVE) and (FDictionary <> nil) then
  1038.         TranslatePrinterDialog(wnd, 0);
  1039.   end;
  1040.  
  1041.   if Assigned(FSetupProc) then
  1042.     Result := CallWindowProc(FSetupProc, wnd, msg, wParam, lParam);
  1043. end;
  1044.  
  1045. function IvPrintDlg(
  1046.   var pd: TPrintDlg;
  1047.   dictionary: TIvDictionary;
  1048.   center: Boolean;
  1049.   parent: HWnd): Bool;
  1050. begin
  1051.   FDictionary := dictionary;
  1052.   FCenter := center;
  1053.   FParent := parent;
  1054.   if (pd.Flags and PD_PRINTSETUP) <> 0 then
  1055.   begin
  1056.     pd.flags := pd.flags or PD_ENABLESETUPHOOK;
  1057.     if Assigned(pd.lpfnSetupHook) then
  1058.       FSetupProc := @pd.lpfnSetupHook
  1059.     else
  1060.       FSetupProc := nil;
  1061.     pd.lpfnSetupHook := IvSetupHook;
  1062.   end
  1063.   else
  1064.   begin
  1065.     pd.flags := pd.flags or PD_ENABLEPRINTHOOK;
  1066.     if Assigned(pd.lpfnPrintHook) then
  1067.       FHookProc := @pd.lpfnPrintHook
  1068.     else
  1069.       FHookProc := nil;
  1070.     pd.lpfnPrintHook := IvPrintHook;
  1071.   end;
  1072.   Result := PrintDlg(pd);
  1073. end;
  1074.  
  1075.  
  1076. { Page Setup dialog }
  1077.  
  1078. {$IFDEF WIN32}
  1079. function TranslatePageSetupDialog(wnd: HWnd; reserved: Integer): Bool; stdcall;
  1080. begin
  1081.   Result := True;
  1082.  
  1083.   { Translates the window text }
  1084.  
  1085.   case GetWindowLong(wnd, GWL_ID) of
  1086.     0: FDictionary.TranslateWindow(wnd, 'Page Setup', False);
  1087.  
  1088.     1: FDictionary.TranslateWindow(wnd, 'OK', False);
  1089.     2: FDictionary.TranslateWindow(wnd, 'Cancel', False);
  1090.     1026: FDictionary.TranslateWindow(wnd, '&Printer...', False);
  1091.  
  1092.     1073: FDictionary.TranslateWindow(wnd, 'Paper', False);
  1093.     1089: FDictionary.TranslateWindow(wnd, 'Si&ze:', True);
  1094.     1090: FDictionary.TranslateWindow(wnd, '&Source:', True);
  1095.  
  1096.     1072: FDictionary.TranslateWindow(wnd, 'Orientation', False);
  1097.     1056: FDictionary.TranslateWindow(wnd, 'P&ortrait', True);
  1098.     1057: FDictionary.TranslateWindow(wnd, 'L&andscape', True);
  1099.  
  1100.     1075:
  1101.       if (FPS.Flags and PSD_INHUNDREDTHSOFMILLIMETERS) <> 0 then
  1102.         FDictionary.TranslateWindow(wnd, 'Margins (millimeters)', False)
  1103.       else
  1104.         FDictionary.TranslateWindow(wnd, 'Margins (inches)', False);
  1105.  
  1106.     1102: FDictionary.TranslateWindow(wnd, '&Left:', True);
  1107.     1103: FDictionary.TranslateWindow(wnd, '&Right:', True);
  1108.     1104: FDictionary.TranslateWindow(wnd, '&Top:', True);
  1109.     1105: FDictionary.TranslateWindow(wnd, '&Bottom:', True);
  1110.   end;
  1111.  
  1112.   { Translates the child controls }
  1113.  
  1114.   EnumChildWindows(wnd, @TranslatePageSetupDialog, 0);
  1115. end;
  1116.  
  1117. function IvPageSetupHook(wnd: HWnd; msg: UINT; wParam: WPARAM; lParam: LPARAM):
  1118. {$IFDEF IVBIDI}
  1119.   UINT;
  1120. {$ELSE}
  1121.   Integer;
  1122. {$ENDIF}
  1123.   stdcall;
  1124. begin
  1125.   Result := 0;
  1126.   case Msg of
  1127.     WM_INITDIALOG:
  1128.       if FCenter then
  1129.         CenterWindow(wnd);
  1130.  
  1131.     WM_ACTIVATE:
  1132.       if (LOWORD(wParam) = WA_ACTIVE) and (FDictionary <> nil) then
  1133.         TranslatePageSetupDialog(wnd, 0);
  1134.   end;
  1135.  
  1136.   if Assigned(FHookProc) then
  1137.     Result := CallWindowProc(FHookProc, wnd, msg, wParam, lParam);
  1138. end;
  1139.  
  1140. function IvPageSetupDlg(
  1141.   var ps: TPageSetupDlg;
  1142.   dictionary: TIvDictionary;
  1143.   center: Boolean;
  1144.   parent: HWnd): Bool;
  1145. begin
  1146.   FDictionary := dictionary;
  1147.   FCenter := center;
  1148.   Fparent := parent;
  1149.   FPS := ps;
  1150.   ps.flags := ps.flags or PSD_ENABLEPAGESETUPHOOK;
  1151.   if Assigned(ps.lpfnPageSetupHook) then
  1152.     FHookProc := @ps.lpfnPageSetupHook
  1153.   else
  1154.     FHookProc := nil;
  1155.   ps.lpfnPageSetupHook := IvPageSetupHook;
  1156.   Result := PageSetupDlg(ps);
  1157. end;
  1158. {$ENDIF}
  1159.  
  1160. end.
  1161.